//
//  UIImageView+Gray.m
//  CqlivingCloud
//
//  Created by xhl_dabaoMac on 2021/12/14.
//  Copyright © 2021 xinhualong. All rights reserved.
//

#import "UIImageView+Gray.h"
#import "UIImage+Gray.h"
#import <objc/runtime.h>
#import "UIResponder+Gray.h"

@implementation UIImageView (Gray)


+ (void)load{
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        method_exchangeImplementations(class_getInstanceMethod(self, @selector(setImage:)), class_getInstanceMethod(self, @selector(c_setImage:)));
    });
}

- (void)c_setImage:(UIImage *)image{
    if ([self.superview isKindOfClass:NSClassFromString(@"UIKBSplitImageView")]) {
        [self c_setImage:image];
        return;
    }
    [self c_setImage:self.changed ? [image grayImage] : image];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setImage:self.image];
}
@end
